{% extends 'base.html' %}

{% block title %}备件入库 - 维修管理系统{% endblock %}

{% block content %}
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title mb-0">备件入库操作</h3>
                </div>
                <div class="card-body">
                    {% if messages %}
                    <div class="alert alert-info">
                        {% for message in messages %}
                        <div>{{ message }}</div>
                        {% endfor %}
                    </div>
                    {% endif %}

                    <form method="post">
                        {% csrf_token %}
                        
                        <div class="mb-3">
                            <label for="spare_part" class="form-label">选择备件</label>
                            <select name="spare_part" id="spare_part" class="form-select" required>
                                <option value="">-- 请选择备件 --</option>
                                {% for part in spare_parts %}
                                <option value="{{ part.id }}">
                                    {{ part.part_number }} - {{ part.name }} (当前库存: {{ part.current_stock }} {{ part.unit }})
                                </option>
                                {% endfor %}
                            </select>
                        </div>

                        <div class="mb-3">
                            <label for="quantity" class="form-label">入库数量</label>
                            <input type="number" name="quantity" id="quantity" class="form-control" 
                                   min="1" required placeholder="请输入入库数量">
                        </div>

                        <div class="mb-3">
                            <label for="notes" class="form-label">备注信息</label>
                            <textarea name="notes" id="notes" class="form-control" rows="3" 
                                      placeholder="请输入入库备注信息（可选）"></textarea>
                        </div>

                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-primary">确认入库</button>
                            <a href="{% url 'spare_parts:inventory_list' %}" class="btn btn-secondary">返回库存列表</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<style>
.card {
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: none;
    border-radius: 8px;
}
.card-header {
    background-color: #2c3e50;
    color: white;
    border-radius: 8px 8px 0 0 !important;
}
.form-control:focus, .form-select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}
.btn {
    border-radius: 5px;
    padding: 10px 20px;
}
</style>
{% endblock %}
